/**
 * PageMarket
 * TrandItemView.java
 * com.android.pagemarket.ui.widget
 * 
 */
package com.android.pagemarket.ui.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.android.pagemarket.R;
import com.android.pagemarket.business.model.Message;
import com.android.pagemarket.ui.activity.trend.TrandDetailActivity;

/*********************************************************
 * @author : zhaohua
 * @version : 2012-11-13
 * @see : 
 * @Copyright : copyrights reserved by personal 2007-2012
 **********************************************************/
public class TrandItemView extends RelativeLayout implements android.view.View.OnClickListener
{
    private TextView name;
    private ImageView is_new;
    private Message data;
    
    public TrandItemView(Context context)
    {
        super(context, null);
    }
    
    public TrandItemView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
    }

    @Override
    protected void onFinishInflate()
    {
        super.onFinishInflate();
        name = (TextView)findViewById(R.id.name);
        is_new = (ImageView)findViewById(R.id.is_new);       
    }
    
    public void bindData(Message msg)
    {
        name.setText(msg.title);
        is_new.setVisibility(msg.isRead ?  View.GONE : View.VISIBLE);
        data = msg;
        setOnClickListener(this);
    }

    @Override
    public void onClick(View v)
    {
        TrandDetailActivity.startActivity(getContext(), data);       
    }
}
